﻿namespace Demo
{
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.Mvc;
    using System.ComponentModel.Composition;
    using Galaxy.Engine;
    using GalaxyEngine.Ui;
    using GalaxyEngine.Ui.Widgets;

    [Export("Demo", typeof(IController))]
    [PartCreationPolicy(CreationPolicy.NonShared)]
    public class DemoController : GalaxyController
    {
        [Import("testBatch", typeof(Galaxy.Ui.IView))]
        Galaxy.Ui.IView testMefBatch;

        //
        // GET: /Demo/
        public ActionResult Index()
        {
            var test = User;
            return View<TestView>(null);
        }

    }

    [Export("testBatch", typeof(Galaxy.Ui.IView))]
    [PartCreationPolicy(CreationPolicy.NonShared)]
    public class TestView : Galaxy.Ui.IView
    {
        public void SetModel(object model)
        {
        }

        public MvcHtmlString Render()
        {
            MasterPage master = new MasterPage(Doctype.HtmlFive);
            Editor editor = new Editor("", "editor");
            editor.SetStyle("width: 100px; height: 100px;");

            UserControl mainContent = new UserControl();
            mainContent.Widgets.Add(editor);

            master.UserControls.Add(mainContent);
            return master.ToMvcHtmlString();
        }
    }
}
